package com.api.shopapi.service.impl;

import com.api.shopapi.entity.RoomType;
import com.api.shopapi.mapper.RoomTypeMapper;
import com.api.shopapi.service.RoomTypeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("RoomTypeServiceImplOne")
public class RoomTypeServiceImpl implements RoomTypeService {

    @Autowired
    private RoomTypeMapper roomTypeMapper;


    @Override
    public int insert(RoomType roomType) {
        return roomTypeMapper.insert(roomType);
    }

    @Override
    public int updateByRoomTypeCode(RoomType roomType) {
        return roomTypeMapper.updateByRoomTypeCode(roomType);
    }

    @Override
    public RoomType getByNameAndInstitutionCode(String name, String institutionCode) {
        return roomTypeMapper.getByNameAndInstitutionCode(name,institutionCode);
    }


    @Override
    public RoomType getByRoomTypeCode(String roomTypeCode) {
        return roomTypeMapper.getByRoomTypeCode(roomTypeCode);
    }


    @Override
    public List<RoomType> getListAllByInstitutionCode(String institutionCode) {
        return roomTypeMapper.getListAllByInstitutionCode(institutionCode);
    }

    @Override
    public PageInfo<RoomType> getPageList(int pageIndex, int pageSize, String institutionCode, String name, int status) {
        PageHelper.startPage(pageIndex, pageSize);
        List<RoomType> roomTypes = roomTypeMapper.getPageList(institutionCode,name,status);
        PageInfo<RoomType> pageInfo = new PageInfo<>(roomTypes);
        return pageInfo;
    }


    @Override
    public
    PageInfo<RoomType> pageByGovCode(int pageIndex, int pageSize, String governmentCode){
        PageHelper.startPage(pageIndex, pageSize);
        List<RoomType> roomTypes = roomTypeMapper.listByGovCode(governmentCode);
        PageInfo<RoomType> pageInfo = new PageInfo<>(roomTypes);
        return pageInfo;
    }

}
